package com.ustze.ocr.type.tencent.utils;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSONObject;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import com.tencentcloudapi.ocr.v20181119.models.RecognizeTableAccurateOCRResponse;
import com.tencentcloudapi.ocr.v20181119.models.TableCellInfo;
import com.tencentcloudapi.ocr.v20181119.models.TableInfo;
import com.ustze.ocr.domain.vo.DayDispatchStatistic;
import com.ustze.ocr.domain.vo.DispatchDetailVo;
import com.ustze.ocr.enums.DispatchPdfEnum;
import com.ustze.ocr.properties.OcrProperties;
import com.ustze.ocr.type.tencent.vo.TencentResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author zk
 * @date 2025/04/11
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class TencentOcrUtils {

    private final OcrProperties ocrProperties;


    public OcrClient createClient() {

        Credential cred = new Credential(ocrProperties.getTencent().getSecretId(), ocrProperties.getTencent().getSecretKey());
        // 实例化一个http选项，可选的，没有特殊需求可以跳过
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint("ocr.tencentcloudapi.com");
        // 实例化一个client选项，可选的，没有特殊需求可以跳过
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        // 实例化要请求产品的client对象,clientProfile是可选的
        OcrClient client = new OcrClient(cred, "", clientProfile);
        return client;
    }




    public static DispatchDetailVo buildVo(RecognizeTableAccurateOCRResponse resp) {
        TableInfo[] tableDetections = resp.getTableDetections();
        if (tableDetections.length == 0) {
            return null;
        }
        TableInfo tableInfo = tableDetections[0];
        TableCellInfo[] cells = tableInfo.getCells();


        List<TencentResponse> ocrResponses = Stream.of(cells).map(data -> BeanUtil.copyProperties(data, TencentResponse.class)).collect(Collectors.toList());

        // 按行分组
        Map<Long, List<TencentResponse>> rowsMap = ocrResponses.stream().collect(Collectors.groupingBy(TencentResponse::getRowBr));

        // 获取基础对象
        DayDispatchStatistic dispatchStatistic = DayDispatchStatistic.build();
        DispatchDetailVo dispatchVo = DispatchDetailVo.buildVo(dispatchStatistic);
        ocrResponses.stream().filter(data -> "备注".equals(data.getText())).findFirst().ifPresent(responseVo -> {
            ocrResponses.stream().filter(remark ->
                    remark.getColTl().equals(responseVo.getColTl())
                            && remark.getColBr().equals(responseVo.getColBr())
                            && !remark.getRowBr().equals(responseVo.getRowBr())
            ).findFirst().ifPresent(responseVo2 -> {
                dispatchVo.setRemark(text(responseVo2.getText()));
            });
        });
        rowsMap.forEach((type, faceList) -> {
            DispatchPdfEnum dispatchPdfEnum = DispatchPdfEnum.getTencentCode(type.intValue());
            if (null != dispatchPdfEnum) {
                List<TencentResponse> responses = faceList.stream()
                        .filter(data -> DispatchPdfEnum.ofTencentType(data.getRowTl().intValue(), data.getRowBr().intValue()))
                        .collect(Collectors.toList());
                dispatchPdfEnum.getTencentBuildData().accept(responses, dispatchVo);
            }
        });

        return dispatchVo;
    }

    public static void main(String[] args) {
        String text = "{\"TableDetections\":[{\"Cells\":[{\"ColTl\":0,\"RowTl\":0,\"ColBr\":9,\"RowBr\":1,\"Text\":\"掘进作业循环情况(次数)\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":0,\"Y\":0},{\"X\":452,\"Y\":0},{\"X\":452,\"Y\":26},{\"X\":0,\"Y\":26}]},{\"ColTl\":9,\"RowTl\":0,\"ColBr\":12,\"RowBr\":1,\"Text\":\"回采作业循环情况(次数)\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":453,\"Y\":0},{\"X\":603,\"Y\":0},{\"X\":603,\"Y\":26},{\"X\":453,\"Y\":26}]},{\"ColTl\":12,\"RowTl\":0,\"ColBr\":13,\"RowBr\":3,\"Text\":\"备注\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":603,\"Y\":0},{\"X\":745,\"Y\":0},{\"X\":745,\"Y\":79},{\"X\":603,\"Y\":79}]},{\"ColTl\":0,\"RowTl\":1,\"ColBr\":3,\"RowBr\":2,\"Text\":\"3305运输顺槽\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":0,\"Y\":26},{\"X\":150,\"Y\":26},{\"X\":150,\"Y\":53},{\"X\":0,\"Y\":53}]},{\"ColTl\":3,\"RowTl\":1,\"ColBr\":6,\"RowBr\":2,\"Text\":\"副斜井上段\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":150,\"Y\":26},{\"X\":301,\"Y\":26},{\"X\":301,\"Y\":53},{\"X\":150,\"Y\":53}]},{\"ColTl\":6,\"RowTl\":1,\"ColBr\":9,\"RowBr\":2,\"Text\":\"副斜井上段(北段)\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":301,\"Y\":26},{\"X\":452,\"Y\":26},{\"X\":453,\"Y\":53},{\"X\":301,\"Y\":53}]},{\"ColTl\":9,\"RowTl\":1,\"ColBr\":12,\"RowBr\":2,\"Text\":\"3306工作面\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":453,\"Y\":26},{\"X\":603,\"Y\":26},{\"X\":603,\"Y\":53},{\"X\":453,\"Y\":53}]},{\"ColTl\":0,\"RowTl\":2,\"ColBr\":1,\"RowBr\":3,\"Text\":\"夜班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":0,\"Y\":53},{\"X\":51,\"Y\":53},{\"X\":51,\"Y\":79},{\"X\":0,\"Y\":79}]},{\"ColTl\":1,\"RowTl\":2,\"ColBr\":2,\"RowBr\":3,\"Text\":\"早班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":51,\"Y\":53},{\"X\":100,\"Y\":53},{\"X\":100,\"Y\":79},{\"X\":51,\"Y\":79}]},{\"ColTl\":2,\"RowTl\":2,\"ColBr\":3,\"RowBr\":3,\"Text\":\"中班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":100,\"Y\":53},{\"X\":150,\"Y\":53},{\"X\":150,\"Y\":79},{\"X\":100,\"Y\":79}]},{\"ColTl\":3,\"RowTl\":2,\"ColBr\":4,\"RowBr\":3,\"Text\":\"夜班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":150,\"Y\":53},{\"X\":202,\"Y\":53},{\"X\":202,\"Y\":79},{\"X\":150,\"Y\":79}]},{\"ColTl\":4,\"RowTl\":2,\"ColBr\":5,\"RowBr\":3,\"Text\":\"早班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":202,\"Y\":53},{\"X\":251,\"Y\":53},{\"X\":251,\"Y\":79},{\"X\":202,\"Y\":79}]},{\"ColTl\":5,\"RowTl\":2,\"ColBr\":6,\"RowBr\":3,\"Text\":\"中班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":251,\"Y\":53},{\"X\":301,\"Y\":53},{\"X\":301,\"Y\":79},{\"X\":251,\"Y\":79}]},{\"ColTl\":6,\"RowTl\":2,\"ColBr\":7,\"RowBr\":3,\"Text\":\"夜班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":301,\"Y\":53},{\"X\":352,\"Y\":53},{\"X\":352,\"Y\":79},{\"X\":301,\"Y\":79}]},{\"ColTl\":7,\"RowTl\":2,\"ColBr\":8,\"RowBr\":3,\"Text\":\"早班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":352,\"Y\":53},{\"X\":402,\"Y\":53},{\"X\":402,\"Y\":79},{\"X\":352,\"Y\":79}]},{\"ColTl\":8,\"RowTl\":2,\"ColBr\":9,\"RowBr\":3,\"Text\":\"中班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":402,\"Y\":53},{\"X\":453,\"Y\":53},{\"X\":453,\"Y\":79},{\"X\":402,\"Y\":79}]},{\"ColTl\":9,\"RowTl\":2,\"ColBr\":10,\"RowBr\":3,\"Text\":\"夜班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":453,\"Y\":53},{\"X\":503,\"Y\":53},{\"X\":503,\"Y\":79},{\"X\":453,\"Y\":79}]},{\"ColTl\":10,\"RowTl\":2,\"ColBr\":11,\"RowBr\":3,\"Text\":\"早班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":503,\"Y\":53},{\"X\":552,\"Y\":53},{\"X\":552,\"Y\":79},{\"X\":503,\"Y\":79}]},{\"ColTl\":11,\"RowTl\":2,\"ColBr\":12,\"RowBr\":3,\"Text\":\"中班\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":553,\"Y\":53},{\"X\":603,\"Y\":53},{\"X\":603,\"Y\":79},{\"X\":553,\"Y\":79}]},{\"ColTl\":0,\"RowTl\":3,\"ColBr\":1,\"RowBr\":4,\"Text\":\"4个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":0,\"Y\":79},{\"X\":51,\"Y\":79},{\"X\":51,\"Y\":179},{\"X\":0,\"Y\":179}]},{\"ColTl\":1,\"RowTl\":3,\"ColBr\":2,\"RowBr\":4,\"Text\":\"0个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":51,\"Y\":79},{\"X\":100,\"Y\":79},{\"X\":100,\"Y\":179},{\"X\":51,\"Y\":179}]},{\"ColTl\":2,\"RowTl\":3,\"ColBr\":3,\"RowBr\":4,\"Text\":\"0个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":100,\"Y\":79},{\"X\":150,\"Y\":79},{\"X\":151,\"Y\":180},{\"X\":100,\"Y\":179}]},{\"ColTl\":3,\"RowTl\":3,\"ColBr\":4,\"RowBr\":4,\"Text\":\"1个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":150,\"Y\":79},{\"X\":202,\"Y\":79},{\"X\":204,\"Y\":180},{\"X\":151,\"Y\":180}]},{\"ColTl\":4,\"RowTl\":3,\"ColBr\":5,\"RowBr\":4,\"Text\":\"0个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":202,\"Y\":79},{\"X\":251,\"Y\":79},{\"X\":254,\"Y\":180},{\"X\":204,\"Y\":180}]},{\"ColTl\":5,\"RowTl\":3,\"ColBr\":6,\"RowBr\":4,\"Text\":\"2个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":251,\"Y\":79},{\"X\":301,\"Y\":79},{\"X\":303,\"Y\":181},{\"X\":254,\"Y\":180}]},{\"ColTl\":6,\"RowTl\":3,\"ColBr\":7,\"RowBr\":4,\"Text\":\"1个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":301,\"Y\":79},{\"X\":352,\"Y\":79},{\"X\":354,\"Y\":181},{\"X\":303,\"Y\":181}]},{\"ColTl\":7,\"RowTl\":3,\"ColBr\":8,\"RowBr\":4,\"Text\":\"0个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":352,\"Y\":79},{\"X\":402,\"Y\":79},{\"X\":404,\"Y\":181},{\"X\":354,\"Y\":181}]},{\"ColTl\":8,\"RowTl\":3,\"ColBr\":9,\"RowBr\":4,\"Text\":\"2个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":402,\"Y\":79},{\"X\":453,\"Y\":79},{\"X\":455,\"Y\":182},{\"X\":404,\"Y\":181}]},{\"ColTl\":9,\"RowTl\":3,\"ColBr\":10,\"RowBr\":4,\"Text\":\"0个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":453,\"Y\":79},{\"X\":503,\"Y\":79},{\"X\":504,\"Y\":182},{\"X\":455,\"Y\":182}]},{\"ColTl\":10,\"RowTl\":3,\"ColBr\":11,\"RowBr\":4,\"Text\":\"0个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":503,\"Y\":79},{\"X\":552,\"Y\":79},{\"X\":553,\"Y\":182},{\"X\":504,\"Y\":182}]},{\"ColTl\":11,\"RowTl\":3,\"ColBr\":12,\"RowBr\":4,\"Text\":\"1个循环\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":552,\"Y\":79},{\"X\":603,\"Y\":79},{\"X\":603,\"Y\":183},{\"X\":553,\"Y\":182}]},{\"ColTl\":12,\"RowTl\":3,\"ColBr\":13,\"RowBr\":5,\"Text\":\"1、3306工作面使用变化\\n情形二(末采)\\n2、副斜井上段使用变化\\n情形四(迎头软岩、顶板\\n硬岩)\\n3、3305运输顺槽变化情\\n形三(过本煤层空巷期\\n间)\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":603,\"Y\":79},{\"X\":745,\"Y\":79},{\"X\":745,\"Y\":298},{\"X\":603,\"Y\":298}]},{\"ColTl\":0,\"RowTl\":4,\"ColBr\":1,\"RowBr\":5,\"Text\":\"正常\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":0,\"Y\":179},{\"X\":51,\"Y\":179},{\"X\":51,\"Y\":298},{\"X\":0,\"Y\":298}]},{\"ColTl\":1,\"RowTl\":4,\"ColBr\":2,\"RowBr\":5,\"Text\":\"检修设\\n备、标\\n准化治\\n理、探\\n水\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":51,\"Y\":179},{\"X\":100,\"Y\":179},{\"X\":101,\"Y\":298},{\"X\":51,\"Y\":298}]},{\"ColTl\":2,\"RowTl\":4,\"ColBr\":3,\"RowBr\":5,\"Text\":\"标准化\\n治理\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":100,\"Y\":179},{\"X\":151,\"Y\":180},{\"X\":152,\"Y\":298},{\"X\":101,\"Y\":298}]},{\"ColTl\":3,\"RowTl\":4,\"ColBr\":4,\"RowBr\":5,\"Text\":\"标准化\\n治理\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":151,\"Y\":180},{\"X\":204,\"Y\":180},{\"X\":206,\"Y\":298},{\"X\":152,\"Y\":298}]},{\"ColTl\":4,\"RowTl\":4,\"ColBr\":5,\"RowBr\":5,\"Text\":\"检修设\\n备、标\\n准化治\\n理\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":204,\"Y\":180},{\"X\":254,\"Y\":180},{\"X\":257,\"Y\":298},{\"X\":206,\"Y\":298}]},{\"ColTl\":5,\"RowTl\":4,\"ColBr\":6,\"RowBr\":5,\"Text\":\"正常\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":254,\"Y\":180},{\"X\":303,\"Y\":181},{\"X\":306,\"Y\":298},{\"X\":257,\"Y\":298}]},{\"ColTl\":6,\"RowTl\":4,\"ColBr\":7,\"RowBr\":5,\"Text\":\"标准化\\n治理\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":303,\"Y\":181},{\"X\":354,\"Y\":181},{\"X\":357,\"Y\":298},{\"X\":306,\"Y\":298}]},{\"ColTl\":7,\"RowTl\":4,\"ColBr\":8,\"RowBr\":5,\"Text\":\"检修设\\n备、标\\n准化治\\n理\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":354,\"Y\":181},{\"X\":404,\"Y\":181},{\"X\":406,\"Y\":298},{\"X\":357,\"Y\":298}]},{\"ColTl\":8,\"RowTl\":4,\"ColBr\":9,\"RowBr\":5,\"Text\":\"正常\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":404,\"Y\":181},{\"X\":455,\"Y\":182},{\"X\":457,\"Y\":298},{\"X\":406,\"Y\":298}]},{\"ColTl\":9,\"RowTl\":4,\"ColBr\":10,\"RowBr\":5,\"Text\":\"标准化\\n治理\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":455,\"Y\":182},{\"X\":504,\"Y\":182},{\"X\":506,\"Y\":298},{\"X\":457,\"Y\":298}]},{\"ColTl\":10,\"RowTl\":4,\"ColBr\":11,\"RowBr\":5,\"Text\":\"检修设\\n备、标\\n准化治\\n理\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":504,\"Y\":182},{\"X\":553,\"Y\":182},{\"X\":555,\"Y\":298},{\"X\":506,\"Y\":298}]},{\"ColTl\":11,\"RowTl\":4,\"ColBr\":12,\"RowBr\":5,\"Text\":\"正常\",\"Type\":\"body\",\"Confidence\":100.0,\"Polygon\":[{\"X\":553,\"Y\":182},{\"X\":603,\"Y\":183},{\"X\":603,\"Y\":298},{\"X\":555,\"Y\":298}]}],\"Type\":1,\"TableCoordPoint\":[{\"X\":0,\"Y\":0},{\"X\":745,\"Y\":0},{\"X\":745,\"Y\":298},{\"X\":0,\"Y\":298}]}],\"Data\":\"UEsDBBQACAgIABp5i1oAAAAAAAAAAAAAAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbLVTy27CMBD8lcjXKjb0UFUVgUMfxxap9ANce5NY+CWvofD3XQc4lFKJCnHyY2ZnZlf2ZLZxtlpDQhN8w8Z8xCrwKmjju4Z9LF7qe1Zhll5LGzw0zAc2m04W2whYUanHhvU5xwchUPXgJPIQwRPShuRkpmPqRJRqKTsQt6PRnVDBZ/C5zkWDTSdP0MqVzdXj7r5IN0zGaI2SmVKJtddHovVekCewAwd7E/GGCKx63pDKrhtCkYkzHI4Ly5nq3mguyWj4V7TQtkaBDmrlqIRDUdWg65iImLKBfc65TPlVOhIURJ4TioKk+SXeh7GokOAsw0K8yPGoW4wJpMYeIDvLsZcJ9HtO9Jh+h9hY8YNwxRx5a09MoQQYkGtOgFbupPGn3L9CWn6GsLyef3EY9n/ZDyCKYRkfcojhe0+/AVBLBwh6lMpxOwEAABwEAABQSwMEFAAICAgAGnmLWgAAAAAAAAAAAAAAAAsAAABfcmVscy8ucm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cm9wcy9jb3JlLnhtbFBLAQIUABQACAgIABp5i1oWBIWVzwEAAJwDAAAUAAAAAAAAAAAAAAAAAKwEAAB4bC9zaGFyZWRTdHJpbmdzLnhtbFBLAQIUABQACAgIABp5i1qGTeiTbwMAAKRHAAANAAAAAAAAAAAAAAAAAL0GAAB4bC9zdHlsZXMueG1sUEsBAhQAFAAICAgAGnmLWk/n4YLYAAAAXAEAAA8AAAAAAAAAAAAAAAAAZwoAAHhsL3dvcmtib29rLnhtbFBLAQIUABQACAgIABp5i1qGAzuR1AAAADMCAAAaAAAAAAAAAAAAAAAAAHwLAAB4bC9fcmVscy93b3JrYm9vay54bWwucmVsc1BLAQIUABQACAgIABp5i1p0lXL0qAMAAM0PAAAYAAAAAAAAAAAAAAAAAJgMAAB4bC93b3Jrc2hlZXRzL3NoZWV0MS54bWxQSwUGAAAAAAkACQA/AgAAhhAAAAAA\",\"PdfPageSize\":0,\"Angle\":0.0,\"RequestId\":\"571a611b-70ce-4212-9b43-5857b2e898fd\"}";
        RecognizeTableAccurateOCRResponse ocrResponse = JSONObject.parseObject(text, RecognizeTableAccurateOCRResponse.class);

        DispatchDetailVo dispatchDetailVo = TencentOcrUtils.buildVo(ocrResponse);
        System.out.println(dispatchDetailVo);

    }

    public static String text(String text) {
        return text.replace("\n", "");
    }

}
